using ProtoModels;
using UnityEngine;

public class HandednessSettings : MonoBehaviour
{
	public UISprite rightHand;

	public UISprite leftHand;

	private string selectedSprite = "button-plastic-green";

	private string deselectedSprite = "button-plastic";

	private void OnEnable()
	{
		DisplayButtons();
	}

	private void DisplayButtons()
	{
		UITools.ChangeSprite(rightHand, (GGPlayerSettings.instance.Model.handedness != 0) ? deselectedSprite : selectedSprite);
		UITools.ChangeSprite(leftHand, (GGPlayerSettings.instance.Model.handedness != ProtoModels.HandednessSettings.LeftHand) ? deselectedSprite : selectedSprite);
	}

	public void OnSelectRight()
	{
		if (GGPlayerSettings.instance.Model.handedness != 0)
		{
			GGPlayerSettings.instance.Model.handedness = ProtoModels.HandednessSettings.RightHand;
			GGPlayerSettings.instance.Save();
			DisplayButtons();
		}
	}

	public void OnSelectLeft()
	{
		if (GGPlayerSettings.instance.Model.handedness != ProtoModels.HandednessSettings.LeftHand)
		{
			GGPlayerSettings.instance.Model.handedness = ProtoModels.HandednessSettings.LeftHand;
			GGPlayerSettings.instance.Save();
			DisplayButtons();
		}
	}
}
